home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Aminet 31
/
Aminet 31 (1999)(Schatztruhe)[!][Jun 1999].iso
/
Aminet
/
dev
/
basic
/
Prefs2000.lha
/
PrefsReader2000
/
PrefsProcedures.ASC
< prev
next >
Wrap
Text File
|
1999-03-19
|
3KB
|
155 lines
;
; The main procedures for Prefs2000, (C) Robert Hutchinson 1999!
; This is the guts of the program,.. Check the docs!
;
NEWTYPE .prefs
Info.s
End NEWTYPE
Dim List Prefs.prefs(300) ; make as big as you like, wont use the mem until you allocate entries
USEPATH Prefs()
BasePointer.w=0 ; Position in the list
BaseCount.w=0 ; Entries in the list
;--- Function definitions
;
;
Function.b ReadPrefs{PrefsFileLoc$}
SHARED Prefs()
If ReadFile(0,PrefsFileLoc$) ; Attempt read lock on specified file
FileInput 0
ClearList Prefs() ; Prepare linked list.
ResetList Prefs()
While NOT Eof(0)
If AddItem(Prefs()) ; If there is space in our list (IE if not over 300), then add the entry
\Info=Edit$(500) ; Grab values
BaseCount+1
Else
Nuked$=Edit$(500) ; Just dump entries over the amount specifed in: DIM Prefs.prefs(300)
EndIf
Wend
CloseFile 0
Function Return True
Else
CloseFile 0
Function Return False
EndIf
End Function
CaseSense Off ;Make a searches non-case sensitive!
Function.s SearchPrefs{SearchString$}
SHARED Prefs()
SHARED BasePointer
BasePointer=0
;--- Prepare list
;
ResetList Prefs()
;--- Our search algorithm
;
While NextItem(Prefs())
BasePointer+1
If NoCont<>1 ; If we havent found a match already
If Left$(\Info,1)<>Chr$(59) ; If not a semicolon (commented line)
If Instr(\Info,SearchString$)>0 ; Do we have a match??
For TMP=0 To Len(\Info)
If GotMatch<>1
If Mid$(\Info,TMP,1)=Chr$(61) ; Do we have an equals symbol
Match$=Mid$(\Info,TMP+2,500) ; get our value
GotMatch=1
NoCont=1
EndIf
EndIf
Next
GotMatch=0
EndIf
EndIf
EndIf
Wend
NoCont=0
Function Return Match$
End Function
Statement ReplaceEntry{SearchString$,Value$}
SHARED Prefs()
SHARED BasePointer
BasePointer=0
;--- Prepare list for parsing!
;
ResetList Prefs()
;--- Our search algorithm
;
While NextItem(Prefs())
BasePointer+1
If NoCont<>1 ; If we havent found a match already
If Left$(\Info,1)<>Chr$(59) ; If not a semicolon (commented line)
If Instr(\Info,SearchString$)>0 ; Do we have a match??
For TMP=0 To Len(\Info)
If GotMatch<>1
If Mid$(\Info,TMP,1)=Chr$(61) ; Do we have an equals symbol
Front$=Left$(\Info,TMP)
NFront$=Front$+Chr$(32)+Value$
\Info=NFront$
GotMatch=1
NoCont=1
EndIf
EndIf
Next
GotMatch=0
EndIf
EndIf
EndIf
Wend
NoCont=0
End Statement
Function.b SavePrefs{PrefsFileLoc$}
SHARED Prefs()
If WriteFile(0,PrefsFileLoc$) ; Attempt write lock on specified file
FileOutput 0
ResetList Prefs()
While NextItem(Prefs())
NPrint \Info
Wend
CloseFile 0
DefaultOutput
Function Return True
Else
CloseFile 0
DefaultOutput
Function Return False
EndIf
End Function
Statement NukePrefs{}
SHARED Prefs()
ClearList Prefs()
End Statement